package lueerror

import "net/http"

// UnhandledErr 未捕捉错误
func UnhandledErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50000",
		error:      err,
		msg:        "服务器开小差了~",
		sendMail:   true,
	}
}

// InvalidRequest 请求参数错误
func InvalidRequest(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40001",
		error:      err,
		msg:        "参数错误",
		sendMail:   false,
	}
}

func Forbidden(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusForbidden,
		code:       "4003",
		error:      err,
		msg:        "无权限访问",
		sendMail:   false,
	}
}

// DbErr postgresql 异常
func DbErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50001",
		error:      err,
		msg:        "服务器开小差了~",
		sendMail:   true,
	}
}

// RedisErr redis 异常
func RedisErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50002",
		error:      err,
		msg:        "服务器开小差了~",
		sendMail:   true,
	}
}

// MqErr 消息中间件异常
func MqErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50003",
		error:      err,
		msg:        "服务器开小差了~",
		sendMail:   true,
	}
}

// GrpcErr grpc 异常
func GrpcErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50004",
		error:      err,
		msg:        "服务器开小差了~",
		sendMail:   true,
	}
}

// OpenErr 授权平台调用错误
func OpenErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50005",
		error:      err,
		msg:        "授权平台调用错误",
		sendMail:   true,
	}
}

// LBSErr 地图查询失败
func LBSErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50005",
		error:      err,
		msg:        "地图查询失败",
		sendMail:   true,
	}
}

func AccountErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50006",
		error:      err,
		msg:        "统一账号调用错误",
		sendMail:   true,
	}
}

func CosErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusInternalServerError,
		code:       "50007",
		error:      err,
		msg:        "COS调用错误",
		sendMail:   true,
	}
}

// InvalidBrand 无效的品牌
func InvalidBrand(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40001",
		error:      err,
		msg:        "无效的品牌",
		sendMail:   false,
	}
}

// CodeVerifyFailed 验证码验证失败
func CodeVerifyFailed(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusUnauthorized,
		code:       "40002",
		error:      err,
		msg:        "验证失败",
		sendMail:   false,
	}
}

// AuthGrantErr 授权失败
func AuthGrantErr(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusUnauthorized,
		code:       "40003",
		error:      err,
		msg:        "授权失败",
		sendMail:   false,
	}
}

// InvalidMobile 手机号错误
func InvalidMobile(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40004",
		error:      err,
		msg:        "手机号格式错误",
		sendMail:   false,
	}
}

// InvalidEmail 邮箱格式错误
func InvalidEmail(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40005",
		error:      err,
		msg:        "邮箱格式错误",
		sendMail:   false,
	}
}

// InvalidStatus 状态类型错误
func InvalidStatus(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40017",
		error:      err,
		msg:        "状态类型错误",
		sendMail:   false,
	}
}

// DirtyData 脏数据
func DirtyData(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusUnprocessableEntity,
		code:       "40018",
		error:      err,
		msg:        "数据有误，请联系后台排查",
		sendMail:   false,
	}
}

// InvalidEmployee 无效的员工
func InvalidEmployee(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40019",
		error:      err,
		msg:        "无效的员工",
		sendMail:   false,
	}
}

// InvalidMall 品牌未开通商城
func InvalidMall(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40020",
		error:      err,
		msg:        "品牌未开通商城",
		sendMail:   false,
	}
}

// InvalidStore 无效的门店
func InvalidStore(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40021",
		error:      err,
		msg:        "无效的门店",
		sendMail:   false,
	}
}

// InvalidRole 无效的角色
func InvalidRole(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40022",
		error:      err,
		msg:        "无效的角色",
		sendMail:   false,
	}
}

// InvalidPermission 不合法的权限
func InvalidPermission(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40023",
		error:      err,
		msg:        "不合法的权限",
		sendMail:   false,
	}
}

// InvalidInventory 无效的仓库
func InvalidInventory(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40024",
		error:      err,
		msg:        "无效的仓库",
		sendMail:   false,
	}
}

// OpIsExist 员工已经存在
func OpIsExist(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40025",
		error:      err,
		msg:        "员工已经存在",
		sendMail:   false,
	}
}

// StoreNotExist 门店不存在
func StoreNotExist(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusNotFound,
		code:       "40021",
		error:      err,
		msg:        "门店不存在",
		sendMail:   false,
	}
}

// EmployeeNotExist 员工不存在
func EmployeeNotExist(err error) LueError {
	return &errInfo{
		httpStatus: http.StatusBadRequest,
		code:       "40022",
		error:      err,
		msg:        "员工不存在",
		sendMail:   false,
	}
}
